Skip to content

perf(sidebar): load tree tables before routines to cut database expand latency#1700

Merged
datlechin merged 3 commits into
TableProApp:mainfrom
desperadoxhy:perf/optimize-table-loading
Jun 17, 2026
Merged

perf(sidebar): load tree tables before routines to cut database expand latency#1700
datlechin merged 3 commits into
TableProApp:mainfrom
desperadoxhy:perf/optimize-table-loading

Conversation

@desperadoxhy

Copy link
Copy Markdown
Contributor

What

Expanding a database in the tree sidebar now loads tables first and fills in procedures and functions in the background.

Why

loadObjects fired three queries through async let: fetchTables, fetchProcedures, fetchFunctions. All three ran on the same driver (one libpq / mariadb connection), and MetadataConnectionPool.runSerially chains same-connection work into strict order, so the async let parallelism was lost. The tree list only appeared after all three round-trips finished in sequence, and most schemas have no routines at all.

Change

  • Split DatabaseTreeMetadataService.objects into tablesState and routinesState, each with its own OnceTask dedup.
  • loadTables runs only fetchTables. The tree renders as soon as it returns, one round-trip.
  • loadRoutines runs procedures and functions on a separate MetadataConnectionPool connection with workload: .bulk, physically isolated from the tables query so they no longer block it.
  • objectsContent keys off tablesLoadState; routines load via a .task after tables render and append when ready. MetadataLoadState.isSettled (added) keeps the empty-state from spinning forever if routines fail.
  • refreshObjects, handleDisconnect, and resetPending updated for the two split dictionaries.

Verification

  • xcodebuild build (Debug, Xcode 27 beta): BUILD SUCCEEDED.
  • SchemaServiceTests: 3/3 pass, no regression.
  • MetadataLoadStateTests (new): 3/3 pass, covers isSettled.

No unit test for DatabaseTreeMetadataService.loadTables/loadRoutines itself: the service reads DatabaseManager.shared and MetadataConnectionPool.shared singletons and cannot take an injected driver (unlike SchemaService, which the existing tests cover). Decoupling that is a separate refactor.

Notes

Built with Xcode 27 beta (DEVELOPER_DIR=/Applications/Xcode-beta.app). Worth a second pass on a stable Xcode before merge.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex usage limits have been reached for code reviews. Please check with the admins of this repo to increase the limits by adding credits.
Credits must be used to enable repository wide code reviews.

@github-actions

Copy link
Copy Markdown
Contributor

Thank you for your contribution! Before we can merge this PR, you need to sign our Contributor License Agreement.

To sign, please comment below with:

I have read the CLA Document and I hereby sign the CLA.


I have read the CLA Document and I hereby sign the CLA.


xuhengyu seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot.

@desperadoxhy

Copy link
Copy Markdown
Contributor Author

I have read the CLA Document and I hereby sign the CLA.

@datlechin datlechin merged commit f2512d9 into TableProApp:main Jun 17, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants